package com.servlet.form;

import java.io.IOException;

import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.listener.ContextListener;
import com.servlet.model.base.Administrator;
import com.servlet.model.database.BaseAcces;
import java.sql.Date;

public class AdminForm extends HttpServlet
{
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
	{
		boolean correct = false;
		
		HttpSession session = request.getSession();
		//BaseAcces base = (BaseAcces) this.config.getServletContext().getAttribute("base");
		
		BaseAcces base = ContextListener.base;
		
		Administrator a = (Administrator) session.getAttribute("admin");
		
		//System.out.println(a);
		
		a.setCoefProfile( Double.parseDouble(request.getParameter("coefProfil") ) );
		a.setCoefPro( Double.parseDouble( request.getParameter("coefPro") ) );
		a.setCoefStudy( Double.parseDouble( request.getParameter("coefEtude") ) );
		
		base.updateAdministrator(a);
		
		response.sendRedirect("admin");

	}
}